<?php
$query_did = sprintf("SELECT * FROM users WHERE id='%s'", $row_courses['did']); 
$did = mysql_query($query_did, $connection) or die(mysql_error());
$row_did = mysql_fetch_assoc($did);

$query_aid = sprintf("SELECT * FROM users WHERE id='%s'", $row_courses['aid']); 
$aid = mysql_query($query_aid, $connection) or die(mysql_error());
$row_aid = mysql_fetch_assoc($aid);
?>